package io.fredia.femicro.txManager.api.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lorne.core.framework.exception.ServiceException;

import io.fredia.femicro.txManager.api.service.ApiAdminService;
import io.fredia.femicro.txManager.compensate.model.TxModel;
import io.fredia.femicro.txManager.compensate.service.CompensateService;
import io.fredia.femicro.txManager.manager.service.MicroService;
import io.fredia.femicro.txManager.model.ModelName;
import io.fredia.femicro.txManager.model.TxState;
import io.fredia.femicro.txManager.redis.service.RedisServerService;

/**
 * create by lorne on 2017/11/12
 */
@Service
public class ApiAdminServiceImpl implements ApiAdminService {

	@Autowired
	private MicroService eurekaService;

	@Autowired
	private RedisServerService redisServerService;

	@Autowired
	private CompensateService compensateService;

	@Override
	public TxState getState() {
		return eurekaService.getState();
	}

	@Override
	public String loadNotifyJson() {
		return redisServerService.loadNotifyJson();
	}

	@Override
	public List<ModelName> modelList() {
		return compensateService.loadModelList();
	}

	@Override
	public List<String> modelTimes(String model) {
		return compensateService.loadCompensateTimes(model);
	}

	@Override
	public List<TxModel> modelInfos(String path) {
		return compensateService.loadCompensateByModelAndTime(path);
	}

	@Override
	public boolean compensate(String path) throws ServiceException {
		return compensateService.executeCompensate(path);
	}

	@Override
	public boolean delCompensate(String path) {
		return compensateService.delCompensate(path);
	}

	@Override
	public boolean hasCompensate() {
		return compensateService.hasCompensate();
	}
}
